<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>未处理预警管理</title>
	<!-- <link rel="stylesheet" href="scripts/bootstrap/css/bootstrap.min.css" />
	<script src="scripts/jquery-3.1.1.min.js" type="text/javascript"></script>
	<script src="scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> -->
	
	<script type="text/javascript">
		function alerts() {
			$.ajax({
				type: 'post',
				url: '${pageContext.request.contextPath}/jsp/alerts/alerts.jsp',
				dataType: 'html',
				success: function(data) {
					$("#main-content").html(data);
				}
	 		});
		}
		
		function stopAlert() {
			var ids = document.getElementsByName("id");
			var str = new Array();
			for(var i=0; i<ids.length; i++) {
				if(ids[i].checked) {
					str.push(ids[i].value);
				}
			}
			$.ajax({
				type: 'post',
				url: 'alerts/stopAlert.action',
				data: {
					str: str.toString()
				},
				success: function() {
					alert_manage(1);
				}
			});
		}
		
		function deleteAlert() {
			var ids = document.getElementsByName("id");
			var str = new Array();
			for(var i=0; i<ids.length; i++) {
				if(ids[i].checked) {
					str.push(ids[i].value);
				}
			}
			$.ajax({
				type: 'post',
				url: 'alerts/deleteAlert.action',
				data: {
					str: str.toString()
				},
				success: function() {
					alert_manage(1);
				}
			});
		}
		
	</script>
</head>

<body>
	<section>
		<div class="row">
    	<div class="col-md-12">
       		<ul class="breadcrumb">
            <li><a href="NyglSystem/index.jsp">能源管理系统</a>
            </li>
            <li>能源管控</li>
            <li><a href="javascript:void(0);" onclick="alerts();">故障预警</a></li>
            <li><a href="javascript:void(0);" onclick="alert_manage(1)">未处理预警</a></li>
            </ul>
       </div>
       </div>
       <div style="width:90%; background-color: white; margin: 50px auto;">
		<div style="height: 20px;"></div>
       <div style="width:90%; margin:50px auto;">
		<div style="margin-bottom:5px;">
			<button class="btn" onclick="stopAlert()">处理预警</button>
			<button class="btn" onclick="deleteAlert()">删除预警</button>
		</div>
		<table class="table table-bordered table-hover">
			<thead>
				<tr>
					<th></th>
					<th>预警设备</th>
					<th>预警等级</th>
					<th>预警类型</th>
					<th>预警内容</th>
					<th>预警时间</th>
				</tr>
			</thead>
			<tbody>
				<c:if test="${list == null}">
				<tr>
	                <td colspan="12"><p style="text-align:center;">没有未处理预警！！！</p></td>
	            </tr>
				</c:if>
				<c:if test="${list != null}">
				<c:forEach items="${list}" var="item"> 
				<tr> 
	    			<td><input type="checkbox" name="id" value="${item.id}"></td>
					<td>${item.deviceNum}</td>
					<td>${item.rankName}</td>
					<td>${item.typeName}</td>
					<td>${item.content}</td>
					<td>${item.time}</td>
				</tr>
				</c:forEach>
				</c:if>
			</tbody>
			<tfoot>
            <tr>
                <td colspan="6">
                	共${totalRows}条记录,${currPage}/${totalPage}页
    			<a href="javascript:void(0);" onclick="alert_manage(1)">第一页</a>
    			<a href="javascript:void(0);" onclick="alert_manage(${currPage-1})">上一页</a>
    			<a href="javascript:void(0);" onclick="alert_manage(${currPage+1})">下一页</a>
    			<a href="javascript:void(0);" onclick="alert_manage(${totalPage})">最末页</a>
    			</td>
            </tr>
        	</tfoot>
		</table>
		</div>
		<div style="height: 20px; clear:both;"></div>
		</div>
	</section>
</body>
</html>